package com.xiezc.dto;


import lombok.Data;

/**
 * 返回前端的数据类
 * Created by Administrator on 2017/5/19.
 */
@Data
public class RespData<T> {

    public RespData() {
        this.code = 200;
    }

    public RespData(T data) {
        this.code = 200;
        this.data = data;
        type = data.getClass().getName();
    }

    public RespData(ExcepEnum exceptionEnum) {
        this.code = exceptionEnum.getCode();
        this.msg = exceptionEnum.getMsg();
    }

    public static RespData success() {
        return new RespData();
    }

    public static <T> RespData<T> success(T data) {
        return new RespData<>(data);
    }

    public static RespData fail(ExcepEnum exceptionEnum) {
        return new RespData(exceptionEnum);
    }

    private String type;

    private int code;

    private String msg;

    private T data;

}
